package com.tianyang.yukuaifuzs.business.main.adapter;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tianyang.yukuaifuzs.R;
import com.tianyang.yukuaifuzs.business.main.bean.ChannelOutput;
import com.tianyang.yukuaifuzs.module.roundview.RoundTextView;

import java.util.ArrayList;

/**
 * Description：渠道
 * Created by xyj on 2024/6/16
 */
public class PosChannelAdapter extends BaseQuickAdapter<ChannelOutput, BaseViewHolder> {

    private int chooseIndex = 0;

    public PosChannelAdapter() {
        super(R.layout.item_pos_channel_dialog, new ArrayList<>());
    }

    public void setChooseIndex(int chooseIndex) {
        this.chooseIndex = chooseIndex;
        this.notifyDataSetChanged();
    }

    @Override
    protected void convert(@NonNull BaseViewHolder helper, ChannelOutput item) {
        if (item != null) {
            helper.setText(R.id.tvChannel, item.getName());
            RoundTextView tvChannel = helper.getView(R.id.tvChannel);
            if (chooseIndex == helper.getLayoutPosition()) {
                tvChannel.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.color_base));
            } else {
                tvChannel.getDelegate().setStrokeColor(ContextCompat.getColor(mContext, R.color.white));
            }
        }
    }
}
